<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<script type="text/javascript">
	$(document).ready(function() {
		$('#pageTitle').text('<spring:message code="findDonoraward.heading" />');
		
		 $('#loginFormSubmit').click(function() {		
		  var v1= $('#donorAwardNumber').val();
		  var v2= $('#donor\\.id').val();
		 //alert(v2);
		 if(v1!='' || v2!=''){		    
		    return true;
		  }
		 alert("Please enter at least one filter criteria");
		 return false;
		});
		
		$("#editDonorForm").validate({
			rules : {
				name : {
					required : true
				}
			}
		});
		$('.edit-donoraward-link').click(function() {
			loadDiv('content', 'showEditDonoraward.do?id=' + $(this).attr('donorawardId'));
		});
		
	});
	
	$('.close-button').click(function() {
		loadDiv('content', 'refreshDashboard.do');
     });
    
     /*
     $('#check-all').click(function() {    
       var checkBox = $('#donorgrid input:checkbox');
       for(var i = 0; i < checkBox.length; i++) {
    	   checkBox[i].checked = this.checked;
       }
	});
    */
</script>
<div id="findDonorDiv">
	<form:form name="editDonorawardForm" id="editDonorawardForm" action="findResultDonoraward.do" method="post" modelAttribute="donoraward">
		<form:hidden path="id" />
		<div class="main_form">
			<div class="form_head">
	    		<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a><br class="clear" />
	    	</div>
	    	<div class="form_cont">
				<table cellspacing="5" width="100%">		
					<tr class="row">
						<td class="input-field" colspan="3">
							<%@ include file="/common/messages.jsp" %>
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.donorAwardNumber" /></td>
						<td class="input-field">
							<form:input path="donorAwardNumber" cssClass="input-full-width text_white" />
							<form:errors path="donorAwardNumber" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message code="editDonoraward.label.donor" /></td>
						<td class="input-field">
							<form:select path="donor.id" cssClass="text_white">
								<form:option value="" label="Select" />
								<form:options items="${donorList}" itemValue="id" itemLabel="donorName" />
							</form:select></td>
							<form:errors path="donor.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
					</tr>
					<tr class="row">
						<td class="input-field" align="center" colspan="3">
							<sj:submit id="loginFormSubmit" cssClass="blue_btn" target="findDonorDiv" key="findDonoraward.button.search" validate="true" tabindex="-1"/>
							<input type="reset" class="blue_btn" id="reset" value="<spring:message code='button.resetSearch' />"  tabindex="-1"/>
						</td>
					</tr>
				</table>
				<div id="donorAward" class="hastable" style="overflow: auto">
				<table class="tablesorter">
				<c:choose>
				   <c:when test="${!empty donorawardList}">	
					<thead>
					<c:if test="${messgae!='null'}">
									<tr>
									<th align="center" colspan="13"><font size="4"><c:out value="${message}"></c:out></font></th>
									</tr>
								</c:if>
					
						<tr>
						    <!--th><spring:message code="common.select.all"/>&#10;<input type="checkbox" id="check-all"></th-->
							<th><spring:message code="donorawardlist.table.heading.donorAwardNumber" /></th>
							<th><spring:message code="donorawardlist.table.heading.acronym" /></th>
							<th><spring:message code="donorawardlist.table.heading.donor" /></th>
							<th><spring:message code="donorawardlist.table.heading.donorAwardDesc" /></th>
							<th><spring:message code="donorawardlist.table.heading.startDate" /></th>
							<th><spring:message code="donorawardlist.table.heading.endDate" /></th>
							<th><spring:message code="donorawardlist.table.heading.directFunds" /></th>
							<th><spring:message code="donorawardlist.table.heading.indirectFunds" /></th>
							<th><spring:message code="donorawardlist.table.heading.obligatedAmount" /></th>
							<th><spring:message code="donorawardlist.table.heading.donorawardtype" /></th>
							<th><spring:message code="donorawardlist.table.heading.donorawardStatus" /></th>
							<!-- 
							<th><spring:message code="donorawardlist.table.heading.city" /></th>
							<th><spring:message code="donorawardlist.table.heading.state" /></th>
							<th><spring:message code="donorawardlist.table.heading.edit" /></th>
							 -->
						</tr>
					</thead>
					<tbody id="donorgrid">
						 <c:forEach items="${donorawardList}" var="donoraward">
							<!--tr><td><input type="checkbox" name="check_donor" id="check_donor" value="${donoraward.id}"></td-->
								<td><a href="javascript://" class="edit-donoraward-link" donorawardId="${donoraward.id}">${donoraward.donorAwardNumber}</a></td>
								<td>${donoraward.donor.donorAcronym}</td>
								<td>${donoraward.donor.donorName}</td>
								<td>${donoraward.donorAwardDesc}</td>
								<td>${donoraward.formattedStartDate}</td>
								<td>${donoraward.formattedEndDate}</td>
								<td><fmt:formatNumber type="currency" value="${donoraward.directFunds}" pattern="$#,##0;"/></td>
								<td><fmt:formatNumber type="currency" value="${donoraward.indirectFunds}" pattern="$#,##0;"/></td>
								<td><fmt:formatNumber type="currency" value="${donoraward.obligatedAmount}" pattern="$#,##0;"/></td>
								<td>${donoraward.donorawardtype.displayName}</td>
								<td>${donoraward.donorawardstatus.displayName}</td>
								<!-- 
								<td>${donoraward.city}</td>
								<td>${donoraward.state}</td>
								 -->
								<%-- <td><a href="javascript://" class="edit-donoraward-link" donorawardId="${donoraward.id}"><spring:message code="donorawardlist.table.link.edit" /></a></td> --%>
							</tr>
							</c:forEach>
							    <!--tr align="center"><td align="left" colspan="12"><input type="button" class="blue_btn" name="view" value="View Selected Donor Awards" align="center"></td></tr-->
							</c:when>
							<c:otherwise>
								<c:if test="${ !empty param.action}">					  
										   <tr><td colspan="12"> Your query has returned 0 records </td></tr>
										 </c:if>  
								</c:otherwise>
						 </c:choose>
					</tbody>
				</table>
				</div>
				<div id="donorawardListPager"></div>
				</div>
			</div>
		</div>
	</form:form>